﻿using System.Drawing;
using System.Windows.Forms;
using CloudShot.Entities;
using CloudShot.Interfaces;
using CloudShot.Settings;

namespace CloudShot
{
	internal sealed class RecordCapturer : ShotCapturer, ICapturer
	{
		private readonly CloudShotSettings _settings;
		private const int FPS = 15;

		public RecordCapturer(string activeStorageName, Color fillColor, CloudShotSettings settings)
			: base(activeStorageName, false, fillColor)
		{
			_settings = settings;
		}

		protected override Image GetImage(Bitmap backgroundImage, CaptureInfo captureInfo, Font labelFont)
		{
			var captureForm = new RecordCaptureForm(captureInfo.ScreenBounds.Location, captureInfo.ScreenBounds.Size, captureInfo.LabelText, labelFont, FPS, _settings);
			if (captureForm.ShowDialog() != DialogResult.OK)
				return null;

			var processingForm = new RecordProcessingForm(captureForm.Images, FPS);
			if (processingForm.ShowDialog() != DialogResult.OK)
				return null;

			return processingForm.Image;
		}
	}
}